//
//  XBActivityTableViewController.m
//  FindPreciousFrameWork
//
//  Created by TianZhen on 16/4/12.
//  Copyright © 2016年 MoreMoney. All rights reserved.
//

#import "XBActivityTableViewController.h"
#import "XBActivityModel.h"
#import "XBActivityCell.h"

@interface XBActivityTableViewController ()

/** 数据 */
@property (nonatomic,strong) NSArray *imageModel;

@end

@implementation XBActivityTableViewController
#define activityCellID @"activityCell"
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerClass:[XBActivityCell class] forCellReuseIdentifier:activityCellID];
    self.tableView.rowHeight = 190;

    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.contentInset = UIEdgeInsetsMake(10, 0, 54, 0);
    
    // 下拉刷新

}

#pragma mark - ======== 数据源 ========
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.imageModel.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    XBActivityCell *cell = [tableView dequeueReusableCellWithIdentifier:activityCellID forIndexPath:indexPath];
    
    if (cell == nil) {
        cell = [[XBActivityCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:activityCellID];
    }
    
    cell.model = self.imageModel[indexPath.row];

    return cell;
}

#pragma mark - ======== 代理 ========
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%s",__func__);
}
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%s",__func__);
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
}

#pragma mark - ======== 懒加载 ========
- (NSArray *)imageModel
{
    if (!_imageModel) {
        _imageModel = [XBActivityModel models];
    }
    return _imageModel;
}
@end